import request from '@/utils/request'

// 获取奶牛档案列表
export const getCattleList = (params) => {
  return request({
    url: '/cattle',
    method: 'get',
    params
  })
}

// 获取奶牛详情
export const getCattleDetail = (id) => {
  return request({
    url: `/cattle/${id}`,
    method: 'get'
  })
}

// 新增奶牛档案
export const createCattle = (data) => {
  return request({
    url: '/cattle',
    method: 'post',
    data
  })
}

// 更新奶牛档案
export const updateCattle = (id, data) => {
  return request({
    url: `/cattle/${id}`,
    method: 'put',
    data
  })
}

// 删除奶牛档案
export const deleteCattle = (id) => {
  return request({
    url: `/cattle/${id}`,
    method: 'delete'
  })
}

// 批量导入
export const importCattle = (file) => {
  const formData = new FormData()
  formData.append('file', file)
  return request({
    url: '/cattle/import',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 批量导出
export const exportCattle = (params) => {
  return request({
    url: '/cattle/export',
    method: 'get',
    params,
    responseType: 'blob'
  })
}

